﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using Models;
using DAL;

namespace 公司CRM客户关系系统.Sale
{
    /// <summary>
    /// SaleChanceWebService 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消对下行的注释。
    [System.Web.Script.Services.ScriptService]
    public class SaleChanceWebService : System.Web.Services.WebService,System.Web.SessionState.IRequiresSessionState
    {
        /// <summary>
        /// 分页查询Chances表
        /// </summary>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        [WebMethod]
        public PagingListForJson<Chances> paging(int pageSize, int pageIndex)
        {
            //查询出分页数据
            PagingList<Chances> list = BaseDAL.Paging<Chances>(pageSize, pageIndex,false);
            //为了不丢失总记录数这个字段，对类型进行转换
            PagingListForJson<Chances> jsonList = new PagingListForJson<Chances>();
            jsonList.total = list.RecordCount;
            jsonList.data = list;
            return jsonList;
        }
        /// <summary>
        /// 删除销售机会表
        /// </summary>
        /// <param name="id">删除的id</param>
        /// <returns></returns>
        [WebMethod]
        public bool DeleteChances(int id)
        {
            return BaseDAL.Delete<Chances>(id) > 0;
        }

        /// <summary>
        /// 查询单个
        /// </summary>
        /// <param name="id">查询的 Chances 表id</param>
        /// <returns></returns>
        [WebMethod]
        public Chances FindChances(int id)
        {
            return BaseDAL.Find<Chances>(id);
        }
        /// <summary>
        /// 查询单个
        /// </summary>
        /// <param name="id">查询的 Users 表id</param>
        /// <returns></returns>
        [WebMethod]
        public Users FindUsersId(int id)
        {
            return BaseDAL.Find<Users>(id);
        }

        [WebMethod]
        //查询全部
        public List<Plans> SelectAll()
        {
            return BaseDAL.SelectAll<Plans>();
        }

    }
}
